package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import bean.Company;
import dao.ChartsDao;

public class SearchServlet extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(request, response);
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub

		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		request.setCharacterEncoding("utf-8");
		String area=request.getParameter("default");
	   		
		ChartsDao dao=new ChartsDao();
		List<Map> list1=dao.findCompany(area);
		String str1="";
		for(Map map1:list1){
			str1+="<option value='"+map1.get("company_id")+"'>"+map1.get("company_name")+"</option>";
		}		
		out.print(str1);
		request.setAttribute("list1",list1);
	}		

}
